<!DOCTYPE html>
<html>

<head>
    <title>游记列表</title>
    <meta charset="utf-8"/>
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
    <link rel="stylesheet" href="/js/bootstrap/css/bootstrap.min.css">
    <script src="/js/jquery/jquery.min.js"></script>
    <script src="/js/bootstrap/js/bootstrap.min.js"></script>
    <link rel="stylesheet" href="/css/font/css/font-awesome.min.css">
    <link rel="stylesheet" href="/css/reset.css"/>
    <link rel="stylesheet" href="/css/travel.css"/>
    <script src="/js/plugins/jrender/jrender.min.js"></script>
    <link rel="stylesheet" href="/js/plugins/dialog2/dialog.css">
    <script src="/js/plugins/dialog2/dialog.min.js"></script>
    <script src="/js/plugins/jquery-form/jquery.form.js"></script>
    <link rel="stylesheet" href="js/plugins/bootstrap-fs-modal-master/dist/css/fs-modal.min.css"/>
    <script src="js/plugins/bootstrap-fs-modal-master/dist/js/fs-modal.min.js"></script>
    <script src="js/common.js"></script>

    <script>

        $(function () {
            var visaCountryId = getParams().visaCountryId;
            $.get("/visas/" + visaCountryId,function (data) {
                console.log(data);
                $("#container").renderValues({list:data},{
                    setPrice:function (item, value) {
                        $(item).attr("value", value);
                    },
                    setVisaCountryId:function (item, value) {
                        $(item).attr("value", value);
                    },
                    setvisaTravelAgencyId:function (item, value) {
                        $(item).attr("value", value);
                    }
                });

            });



            var user = JSON.parse(sessionStorage.getItem('user'));
            console.log(user.id);

            $("#container").on("click", ".btnlg", function () {

                $("#editform").ajaxSubmit({
                    beforeSubmit:function (params, form, options) {
                        params.push({name:"user.id",value:user.id});
                    },
                    success:function (data) {
                        if (data.success){
                            $(document).dialog({
                                content: '预定成功!',
                            });
                        }else{
                            $.messager.confirm("温馨提示",data.msg)
                        }


                    }
                })
            })

        })
    </script>

    <style>
        .color{
            color: #D99531;
            position: relative;
            width: 120px;
            font-family: "Microsoft YaHei", "宋体", "Segoe UI", "Lucida Grande", Helvetica, Arial, sans-serif, FreeSans, Arimo;

        }
        .price{
            color: red;
            padding: 5px;
            height: 30px;
        }
    </style>
</head>

<body>

<div class="search-head">
    <div class="row nav-search">
        <div class="col-2">
            <a href="index.html">
                <span><i class="fa fa-chevron-left fa-2x"></i></span>
            </a>
        </div>
        <div class="col-10">
            <div class="input-group-sm search">
                <input class="form-control searchBtn" placeholder="搜国家">
            </div>
        </div>
    </div>
</div>

<div class="container" id="container">
    <div render-loop="list">
        <div>
        <h4 render-html="list.visaCountry.country" class="color"></h4>
        <div id="allTravels">
            <div class="row detail">
                    详细介绍:<h4 render-html="list.introduce"></h4>
                    旅行社:<h3 render-html="list.visaTravelAgency.travelAgency"></h3><hr/>
                   金额:<div class="price"> <h3 render-html="list.price"></h3></div>RMB

                <form action="/visas/save" method="post" id="editform">
                    <input type="hidden" name="price" render-key="list.price" render-fun="setPrice">
                    <input type="hidden" name="visaCountry.id" render-key="list.visaCountry.id" render-fun="setVisaCountryId">
                    <input type="hidden" name="visaTravelAgency.id" render-key="list.visaTravelAgency.id" render-fun="setvisaTravelAgencyId">
                <button type="button" class="btn btn-primary btnlg" data-toggle="modal" data-target="#myyModal">
                    预定
                </button>
                </form>

            </div>
        </div>
        </div>

    </div>
</div>

<!-- 模态窗口 -->
<div class="modal fade modal-fullscreen" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
    <div class="modal-dialog" role="document">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
                <h7 class="modal-title" id="myModalLabel">预定</h7>
            </div>


            <div class="modal-body">
                <div render-loop="list">
                <form action="/visas/save" method="post" id="editformm">
                    <input type="text" name="price" render-value="list.price">元
                    <input type="text" name="visaCountry.id" render-value="list.visaCountry.id">
                    <input type="text" name="visaTravelAgency.id" render-value="list.visaTravelAgency.id">
                </form>

            </div>

            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
                <button type="button" class="btn btn-primary submitbtn">保存</button>
            </div>
        </div>
    </div>
</div>

</body>

</html>